/*
*	(*^。^*) TFrameWork License (*^。^*)
*/

/*
 *  Title : 录制数据类 
 *          
 *  Description :  
 *          保存录制的数据
 *          录制数据的函数
 *          
 *  Date : 
 *
 *  Author : DengPing
 *
 *  Modify : 
 */

using System;
using System.Collections.Generic;
using UnityEngine;

namespace TFrameWork.Module.ActionEditor
{
    [System.Serializable]
    public abstract class RecordTrackEventBase : TrackEventBase
    {
        [NonSerialized] public Transform recordTransform;

        /// <summary>
        /// 录制节点名称
        /// </summary>
        public string rocordTransformName;

        public Vector3 position = Vector3.zero;
        public Vector3 rotate = Vector3.zero;
        public Vector3 scale = Vector3.one;

        public Matrix4x4 localMatrix4X4 => Matrix4x4.TRS(position, Quaternion.Euler(rotate), scale);

        /// <summary>
        /// 录制节点信息
        /// </summary>
        public Dictionary<int, RecordEventData> recordEventDatas = new Dictionary<int, RecordEventData>();

        //子节点，相对于父节点的每层的Transform

        [NonSerialized] public List<Transform> relativelocalToWrold;

        public override object Clone()
        { 
            var clone = base.Clone() as RecordTrackEventBase;
            clone.recordEventDatas = new Dictionary<int, RecordEventData>();
            foreach (var data in recordEventDatas) 
            { 
                var key = data.Key;
                var value = data.Value.Clone() is RecordEventData ? (RecordEventData)data.Value.Clone() : default;
                clone.recordEventDatas.Add(data.Key, value);
            }

            return clone;
        }
    }
}
